
#include "base_malloclib.h"

/* 引入brkheap */
#include <metalc/mlos/brkheap.h>

// #ifdef __aarch64__
// 	#define TLSF_APDS	ccsync
// #else
// 	#define TLSF_APDS	sffwd
// #endif
#define TLSF_APDS	cacsffwd
/* 定义tlsf */
#include <metalc/mlayer/tlsf.h>
static tlsf_obj_t *ptlsf;
DEF_TLSF_MLAYER(tlsf, ptlsf, 4, MLAYER_SZ_MAXBIT, 4 * SIZE_1G, 5, page_alloc)

/* xorcode层 */
#include <metalc/mladt/xorcode.h>

#include <metalc/mladt/delayed.h>
DEF_DELAYED_MLAYER(delayed_normal, 64 * 1024, mlcc_palloc, output)


/* 组合 */
COMPOSE_MLAYER(malloc_tlsf_sd, mallocapi, xor_tail, delayed_normal, tlsf, brkheap)


/* 定义tls */
DEF_MTLS_PTHREAD(GET_MLAYER_OBJNR(malloc_tlsf_sd), 4096, mlcc_palloc, mp_coreid)


/* mlcc和mtls一定要放在第一位初始化 */
DEF_SYSINIT(malloc_perm_pool, malloc_tlsf_sd, mtls)
DEF_CFLOWFIN(mtls)
DEF_CFLOWINIT(mtls, malloc_tlsf_sd)
DEF_SYSFIN(__omega)